/**
 * Created by Administrator on 2017/3/21.
 */
import React, {Component} from 'react';
import {connect} from 'dva';
class AddPoliciesForm extends Component {
  constructor(props) {
    super(props);
    this.state = {
      showCustom: false,
      content:this.props.editRecord.content,
    };
  }

  componentDidMount() {
    if(this.props.editRecord.type===2){

      const container = document.getElementById('jsoneditor2');
      const options = {
        mode: 'view',
        modes: ['view'], // allowed modes
        mainMenuBar:false,
        onError: function (err) {
        },
        onModeChange: function (newMode, oldMode) {
          console.log('Mode switched from', oldMode, 'to', newMode);
        }
      };
      this.editor = new window.JSONEditor(container, options, this.state.content);
      console.log('this.edito',this.editor)
    }
  }
  render() {

    const props=this.props
    return (
      <div>
        {
          this.props.editRecord.type===2?
          <div
            id='jsoneditor2'
            ref={(ref) => {
              this.editorRef = ref;
            }}
            style={{height: '300px', width: '100%'}}
          />
          :
            <div>
              {this.state.content}
            </div>
        }
      </div>

    );
  }
}

export default AddPoliciesForm


